package com.gite.nouette.admin.implementation.integrator.builder.command;

import com.gite.nouette.admin.contract.integrator.builder.command.IBuilderCommandRemoveModule;
import com.gite.nouette.admin.contract.integrator.factory.IFactoryModel;
import com.gite.nouette.admin.contract.model.ICommand;
import com.gite.nouette.admin.contract.model.IManager;
import com.gite.nouette.admin.contract.model.command.ICommandRemoveModule;
import com.gite.nouette.admin.contract.observer.IObserver;
import com.gite.nouette.admin.implementation.integrator.builder.AbstractBuilderCommand;

public class BuilderCommandRemoveModuleImpl extends AbstractBuilderCommand
		implements IBuilderCommandRemoveModule {

	private ICommandRemoveModule product;
	private IManager manager;
	private IObserver<ICommand>[] observers;

	public BuilderCommandRemoveModuleImpl(IFactoryModel factoryModel,
			IManager manager, IObserver<ICommand>... observers) {
		super(factoryModel);
		setManager(manager);
		setObservers(observers);
	}

	@Override
	public ICommandRemoveModule getProduct() {
		return this.product;
	}

	public void setProduct(ICommandRemoveModule product) {
		this.product = product;
	}

	public IManager getManager() {
		return this.manager;
	}

	public void setManager(IManager manager) {
		this.manager = manager;
	}

	private IObserver<ICommand>[] getObservers() {
		return this.observers;
	}

	private void setObservers(IObserver<ICommand>[] observers) {
		this.observers = observers;
	}

	@Override
	public void createNewProduct() {
		setProduct(getFactoryModel().getCommandRemoveModule());
	}

	@Override
	public void buildManager() {
		getProduct().setManager(getManager());
	}

	@Override
	public void buildName() {
		getProduct().setName("");
	}

	@Override
	public void buildObservers() {
		for (IObserver<ICommand> observer : getObservers()) {
			getProduct().addObserver(observer);
		}
	}
}
